#include "cminibuffer.h"
#include "Utils.h"
#include <string.h>

CMiniBuffer::CMiniBuffer(int64_t nSize, bool bAutoRelease)
{
    m_nSize = nSize;
    m_bAutoRelease = bAutoRelease;
    m_pData = new char[(int)nSize];
    memset(m_pData, 0, (size_t)nSize);
}

CMiniBuffer::~CMiniBuffer()
{
    if(m_bAutoRelease) {
        DEL_ARR(m_pData);
        m_nSize = 0;
    }
}

void CMiniBuffer::Release()
{
    DEL_ARR(m_pData);
    m_nSize = 0;
}


int64_t CMiniBuffer::GetSize()
{
    return m_nSize;
}

char* CMiniBuffer::GetBuffer()
{
    return m_pData;
}

//CMiniBuffer::operator PSTR()
//{
//	return m_pData;
//}

void CMiniBuffer::EnableAutoRelease(bool bAutoRelease)
{
    m_bAutoRelease = bAutoRelease;
}

bool CMiniBuffer::IsAutoRelease()
{
    return m_bAutoRelease;
}
